const WebpackMerge = require('webpack-merge');
const common = require('./webpack.common.js');
const path = require('path');
const apiMocker = require('mocker-api');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const pageConfig = require('./webpack.page.js');

module.exports = WebpackMerge.merge(common(true), {
	devtool: 'inline-source-map',
	mode: 'development',
	devServer: {
		// setupMiddlewares: (middlewares, devServer) => {
		// 	apiMocker(devServer.app, path.resolve('./mock/index.js'));

		// 	return middlewares;
		// },
		hot: true,
		proxy: [{
			context: ['/api/'],
			target: 'http://116.233.134.112:7508/',
		}, {
			context: ['/configs/'],
			target: 'http://113.44.8.184:85/',
			//target: 'http://localhost:17605/',
		},
		{
			context: ['/websocket/'],
			target: 'http://113.44.8.184/websocket/',
		},
		{
			context: ['/image2/'],
			target: 'http://localhost:17808/',
		},
		{
			context: ['/images/202412/'],
			target: 'http://localhost:17808/',
		},
		{
			context: ['/images/usersign/'],
			target: 'http://localhost:17808/',
		},
		{
			context: ['/res/'],
			target: 'http://118.25.18.233/',
			changeOrigin: true
		},
		{
			context: ['/images/yxinmt_h5/'],
			target: 'http://118.25.18.233:85/',
		}]
	},
	output: {
		filename: '[name].bundle.js',
		path: path.resolve(__dirname, 'dist'),
		chunkFilename: '[name].js',
		publicPath: ''
	},
	plugins: [
		new CopyWebpackPlugin({ patterns: pageConfig.copyConfigs })
	]
})
